package Bitwise_operatio;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-01-29
 * Time:19:42
 * Text：消失的数字
 */
public class Text2 {
//    位运算
    public int missingNumber2(int[] nums) {
        int num=0;
        for(int a:nums){
            num^=a;
        }
        for(int i=0;i<=nums.length;i++){
            num^=i;
        }
        return num;
    }
    public int missingNumber(int[] nums) {
        int num=nums.length*(nums.length+1)/2;
        for(int a:nums){
            num-=a;
        }
        return num;
    }
}
